﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace MIXOnline.Descry
{
    public partial class Pin : Canvas
    {
        public Pin()
        {
            InitializeComponent();

            startOscillation();
        }

        private void startOscillation()
        {
            System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
            dt.Interval = new TimeSpan(0, 0, 0, new Random().Next(0, 5), new Random().Next(0, 1000));
            dt.Tick += new EventHandler(dt_Tick);
            dt.Start();
        }

        private void dt_Tick(object sender, EventArgs e)
        {
            OscillateAnimation.Begin();
            (sender as System.Windows.Threading.DispatcherTimer).Stop();
        }

        private Point _location;

        public Point Location
        {
            get { return _location; }
            set { _location = value; }
        }

        private Point _scaleCenter;

        public Point ScaleCenter
        {
            get { return _scaleCenter; }
            set { _scaleCenter = value; }
        }

        private void image_MouseEnter(object sender, MouseEventArgs e)
        {
            ScaleUpAnimation.Begin();
            OscillateAnimation.Pause();
        }

        private void image_MouseLeave(object sender, MouseEventArgs e)
        {
            ScaleDownAnimation.Begin();
            OscillateAnimation.Resume();
        }


    }
}
